package com.itheima.sh.feign;

import com.itheima.sh.feign.fallback.UserFeignApiFallBack;
import com.itheima.sh.pojos.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author: 飞羽鸿蒙
 * @date: 2020/12/20 19:32
 */
// feign客户端

@FeignClient(value = "user-service",fallback = UserFeignApiFallBack.class) // Eureka 获取到服务实例名称,此名称是服务方注册到Eureka时自定义的,此名称是spring.application.name=
public interface UserFeignApi {

    /**
     * 服务方提供接口方法:
     *      即此方法与user_service模块的业务褒词一致
     * @param username
     * @return
     */
    @GetMapping("/user/{id}") // feign对springmvc注解的增强
    public User queryById(@PathVariable("id") String username);

}
